home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / gdb.new / gdb-4.0 / gdb / gdb.info-4 < prev    next >
Encoding:
Text File  |  1991-08-24  |  48.5 KB  |  1,321 lines

  1. Info file gdb.info, produced by Makeinfo, -*- Text -*- from input
  2. file gdb-all.texi.
  3.  
  4.    This file documents the GNU debugger GDB.
  5.  
  6.    Copyright (C) 1988, 1989, 1990, 1991 Free Software Foundation, Inc.
  7.  
  8.    Permission is granted to make and distribute verbatim copies of
  9. this
  10. manual provided the copyright notice and this permission notice are
  11. preserved on all copies.
  12.  
  13.    Permission is granted to copy and distribute modified versions of
  14. this
  15. manual under the conditions for verbatim copying, provided also that
  16. the section entitled "GNU General Public License" is included
  17. exactly as in the original, and provided that the entire resulting
  18. derived work is distributed under the terms of a permission notice
  19. identical to this one.
  20.  
  21.    Permission is granted to copy and distribute translations of this
  22. manual into another language, under the above conditions for
  23. modified versions, except that the section entitled "GNU General
  24. Public License" may be included in a translation approved by the
  25. Free Software Foundation instead of in the original English.
  26.  
  27. 
  28. File: gdb.info,  Node: Jumping,  Next: Signaling,  Prev: Assignment,  Up: Altering
  29.  
  30. Continuing at a Different Address
  31. =================================
  32.  
  33.    Ordinarily, when you continue the program, you do so at the place
  34. where it stopped, with the `continue' command.  You can instead
  35. continue at an address of your own choosing, with the following
  36. commands:
  37.  
  38. `jump LINESPEC'
  39.      Resume execution at line LINESPEC.  Execution will stop
  40.      immediately if there is a breakpoint there.  *Note List:: for a
  41.      description of the different forms of LINESPEC.
  42.  
  43.      The `jump' command does not change the current stack frame, or
  44.      the stack pointer, or the contents of any memory location or
  45.      any register other than the program counter.  If line LINESPEC
  46.      is in a different function from the one currently executing,
  47.      the results may be bizarre if the two functions expect
  48.      different patterns of arguments or of local variables.  For
  49.      this
  50.      reason, the `jump' command requests confirmation if the
  51.      specified line is not in the function currently executing. 
  52.      However, even bizarre results are predictable if you are well
  53.      acquainted with the machine-language code of the program.
  54.  
  55. `jump *ADDRESS'
  56.      Resume execution at the instruction at address ADDRESS.
  57.  
  58.    You can get much the same effect as the `jump' command by storing
  59. a new value into the register `$pc'.  The difference is that this
  60. does not start the program running; it only changes the address
  61. where it *will* run when it is continued.  For example,
  62.  
  63.      set $pc = 0x485
  64.  
  65. causes the next `continue' command or stepping command to execute at
  66. address 0x485, rather than at the address where the program stopped.
  67. *Note Continuing and Stepping::.
  68.  
  69.    The most common occasion to use the `jump' command is to back up,
  70. perhaps with more breakpoints set, over a portion of a program that
  71. has already executed, in order to examine its execution in more
  72. detail.
  73.  
  74. 
  75. File: gdb.info,  Node: Signaling,  Next: Returning,  Prev: Jumping,  Up: Altering
  76.  
  77. Giving the Program a Signal
  78. ===========================
  79.  
  80. `signal SIGNALNUM'
  81.      Resume execution where the program stopped, but give it
  82.      immediately the signal number SIGNALNUM.
  83.  
  84.      Alternatively, if SIGNALNUM is zero, continue execution without
  85.      giving a signal.  This is useful when the program stopped on
  86.      account of a signal and would ordinary see the signal when
  87.      resumed with the `continue' command; `signal 0' causes it to
  88.      resume without a signal.
  89.  
  90.      `signal' does not repeat when you press RET a second time after
  91.      executing the command.
  92.  
  93. 
  94. File: gdb.info,  Node: Returning,  Next: Calling,  Prev: Signaling,  Up: Altering
  95.  
  96. Returning from a Function
  97. =========================
  98.  
  99. `return'
  100. `return EXPRESSION'
  101.      You can cancel execution of a function call with the `return'
  102.      command.  If you give an EXPRESSION argument, its value is used
  103.      as the function's return value.
  104.  
  105.    When you use `return', GDB discards the selected stack frame (and
  106. all frames within it).  You can think of this as making the
  107. discarded frame return prematurely.  If you wish to specify a value
  108. to be returned, give that value as the argument to `return'.
  109.  
  110.    This pops the selected stack frame (*note Selection::.), and any
  111. other frames inside of it, leaving its caller as the innermost
  112. remaining frame.  That frame becomes selected.  The specified value
  113. is stored in the registers used for returning values of functions.
  114.  
  115.    The `return' command does not resume execution; it leaves the
  116. program stopped in the state that would exist if the function had
  117. just returned.  In contrast, the `finish' command (*note Continuing
  118. and Stepping::.) resumes execution until the selected stack frame
  119. returns naturally.
  120.  
  121. 
  122. File: gdb.info,  Node: Calling,  Prev: Returning,  Up: Altering
  123.  
  124. Calling your Program's Functions
  125. ================================
  126.  
  127. `call EXPR'
  128.      Evaluate the expression EXPR without displaying `void' returned
  129.      values.
  130.  
  131.    You can use this variant of the `print' command if you want to
  132. execute a function from your program, but without cluttering the
  133. output with `void' returned values.  The result is printed and saved
  134. in the value history, if it is not void.
  135.  
  136. 
  137. File: gdb.info,  Node: GDB Files,  Next: Targets,  Prev: Altering,  Up: Top
  138.  
  139. GDB's Files
  140. ***********
  141.  
  142. * Menu:
  143.  
  144. * Files::                       Commands to Specify Files
  145. * Symbol Errors::               Errors Reading Symbol Files
  146.  
  147. 
  148. File: gdb.info,  Node: Files,  Next: Symbol Errors,  Prev: GDB Files,  Up: GDB Files
  149.  
  150. Commands to Specify Files
  151. =========================
  152.  
  153.    GDB needs to know the file name of the program to be debugged,
  154. both in order to read its symbol table and in order to start the
  155. program.  To debug a core dump of a previous run, GDB must be told
  156. the file name of the core dump.
  157.  
  158.    The usual way to specify the executable and core dump file names
  159. is with the command arguments given when you start GDB, as discussed
  160. in *note Invocation::..
  161.  
  162.    Occasionally it is necessary to change to a different file during
  163. a GDB session.  Or you may run GDB and forget to specify the files
  164. you want to use.  In these situations the GDB commands to specify
  165. new files are useful.
  166.  
  167. `file FILENAME'
  168.      Use FILENAME as the program to be debugged.  It is read for its
  169.      symbols and for the contents of pure memory.  It is also the
  170.      program executed when you use the `run' command.  If you do not
  171.      specify a directory and the file is not found in GDB's working
  172.      directory,
  173.  
  174.      GDB uses the environment variable `PATH' as a list of
  175.      directories to search, just as the shell does when looking for
  176.      a
  177.      program to run.  You can change the value of this variable, for
  178.      both GDB and your program, using the `path' command.
  179.  
  180.      `file' with no argument makes GDB discard any information it has
  181.      on both executable file and the symbol table.
  182.  
  183. `exec-file FILENAME'
  184.      Specify that the program to be run (but not the symbol table) is
  185.      found in FILENAME.  GDB will search the environment variable
  186.      `PATH' if necessary to locate the program.
  187.  
  188. `symbol-file FILENAME'
  189.      Read symbol table information from file FILENAME.  `PATH' is
  190.      searched when necessary.  Use the `file' command to get both
  191.      symbol table and program to run from the same file.
  192.  
  193.      `symbol-file' with no argument clears out GDB's information on
  194.      your program's symbol table.
  195.  
  196.      The `symbol-file' command causes GDB to forget the contents of
  197.      its convenience variables, the value history, and all
  198.      breakpoints and auto-display expressions.  This is because they
  199.     
  200.      may contain pointers to the internal data recording symbols and
  201.      data types, which are part of the old symbol table data being
  202.      discarded inside GDB.
  203.  
  204.      `symbol-file' will not repeat if you press RET again after
  205.      executing it once.
  206.  
  207.      On some kinds of object files, the `symbol-file' command does
  208.      not actually read the symbol table in full right away. 
  209.      Instead, it scans the symbol table quickly to find which source
  210.      files and which symbols are present.  The details are read
  211.      later, one source file at a time, when they are needed.
  212.  
  213.      The purpose of this two-stage reading strategy is to make GDB
  214.      start up faster.  For the most part, it is invisible except for
  215.      occasional pauses while the symbol table details for a
  216.      particular source file are being read.  (The `set verbose'
  217.      command can turn these pauses into messages if desired. *Note
  218.      Messages/Warnings::).
  219.  
  220.      When the symbol table is stored in COFF format, `symbol-file'
  221.      does read the symbol table data in full right away.  We haven't
  222.      implemented the two-stage strategy for COFF yet.
  223.  
  224.      When GDB is configured for a particular environment, it will
  225.      understand debugging information in whatever format is the
  226.      standard generated for that environment; you may use either a
  227.      GNU compiler, or other compilers that adhere to the local
  228.      conventions.  Best results are usually obtained from GNU
  229.      compilers; for example, using `gcc' you can generate debugging
  230.      information for optimized code.
  231.  
  232. `core-file FILENAME'
  233. `core FILENAME'
  234.      Specify the whereabouts of a core dump file to be used as the
  235.      "contents of memory".  Traditionally, core files contain only
  236.      some parts of the address space of the process that generated
  237.      them; GDB can access the executable file itself for other parts.
  238.  
  239.      `core-file' with no argument specifies that no core file is to
  240.      be used.
  241.  
  242.      Note that the core file is ignored when your program is actually
  243.      running under GDB.  So, if you have been running the program
  244.      and you wish to debug a core file instead, you must kill the
  245.      subprocess in which the program is running.  To do this, use
  246.      the `kill' command (*note Kill Process::.).
  247.  
  248. `load FILENAME'
  249.      Depending on what remote debugging facilities are configured
  250.      into GDB, the `load' command may be available.  Where it
  251.      exists, it is meant to make FILENAME (an executable) available
  252.      for debugging on the remote system--by downloading, or dynamic
  253.      linking, for example.  `load' also records FILENAME's symbol
  254.      table in GDB, like the `add-symbol-file' command.
  255.  
  256.      If `load' is not available on your GDB, attempting to execute it
  257.      gets the error message "`You can't do that when your target is
  258.      ...'"
  259.  
  260.      On VxWorks, `load' will dynamically link FILENAME on the current
  261.      target system as well as adding its symbols in GDB.
  262.  
  263.      With the Nindy interface to an Intel 960 board, `load' will
  264.      download FILENAME to the 960 as well as adding its symbols in
  265.      GDB.
  266.  
  267.      `load' will not repeat if you press RET again after using it.
  268.  
  269. `add-symbol-file FILENAME ADDRESS'
  270.      The `add-symbol-file' command reads additional symbol table
  271.      information from the file FILENAME.  You would use this command
  272.      when FILENAME has been dynamically loaded (by some other means)
  273.      into the program that is running.  ADDRESS should be the memory
  274.      address at which the file has been loaded; GDB cannot figure
  275.      this out for itself.
  276.  
  277.      The symbol table of the file FILENAME is added to the symbol
  278.      table originally read with the `symbol-file' command.  You can
  279.      use the `add-symbol-file' command any number of times; the new
  280.      symbol data thus read keeps adding to the old.  To discard all
  281.      old symbol data instead, use the `symbol-file' command.
  282.  
  283.      `add-symbol-file' will not repeat if you press RET after using it.
  284.  
  285. `info files'
  286. `info target'
  287.      `info files' and `info target' are synonymous; both print the
  288.      current targets (*note Targets::.), including the names of the
  289.      executable and core dump files currently in use by GDB, and the
  290.      files from which symbols were loaded.  The command `help
  291.      targets' lists all possible targets rather than current ones.
  292.  
  293.    All file-specifying commands allow both absolute and relative file
  294. names as arguments.  GDB always converts the file name to an
  295. absolute path name and remembers it that way.
  296.  
  297.    GDB supports the SunOS shared library format.  Symbols from a
  298. shared library cannot be referenced before the shared library has
  299. been linked with the program.  (That is to say, until after you type
  300. `run' and  the function `main' has been entered; or when examining
  301. core files.)  Once the shared library has been linked in, you can
  302. use
  303. the following commands:
  304.  
  305. `sharedlibrary REGEX'
  306. `share REGEX'
  307.      Load shared object library symbols for files matching a UNIX
  308.      regular expression.
  309.  
  310. `share'
  311. `sharedlibrary'
  312.      Load symbols for all shared libraries.
  313.  
  314. `info share'
  315. `info sharedlibrary'
  316.      Print the names of the shared libraries which you have loaded
  317.      with the `sharedlibrary' command.
  318.  
  319.    `sharedlibrary' does not repeat automatically when you press RET
  320. after using it once.
  321.  
  322. 
  323. File: gdb.info,  Node: Symbol Errors,  Prev: Files,  Up: GDB Files
  324.  
  325. Errors Reading Symbol Files
  326. ===========================
  327.  
  328.    While reading a symbol file, GDB will occasionally encounter
  329. problems, such as symbol types it does not recognize, or known bugs
  330. in compiler output.  By default, GDB does not notify you of such
  331. problems, since they're relatively common and primarily of interest
  332. to people debugging compilers.  If you are interested in seeing
  333. information about ill-constructed symbol tables, you can either ask
  334. GDB to print only one message about each such type of problem, no
  335. matter how many times the problem occurs; or you can ask GDB to
  336. print more messages, to see how many times the problems occur, with
  337. the `set complaints' command (*Note Messages/Warnings::).
  338.  
  339.    The messages currently printed, and their meanings, are:
  340.  
  341. `inner block not inside outer block in SYMBOL'
  342.      The symbol information shows where symbol scopes begin and end
  343.      (such as at the start of a function or a block of statements). 
  344.      This error indicates that an inner scope block is not fully
  345.      contained in its outer scope blocks.
  346.  
  347.      GDB circumvents the problem by treating the inner block as if it
  348.      had the same scope as the outer block.  In the error message,
  349.      SYMBOL may be shown as "`(don't know)'" if the outer block is
  350.      not a function.
  351.  
  352. `block at ADDRESS out of order'
  353.      The symbol information for symbol scope blocks should occur in 
  354.      order of increasing addresses.  This error indicates that it
  355.      does not do so.
  356.  
  357.      GDB does not circumvent this problem, and will have trouble
  358.      locating symbols in the source file whose symbols being read. 
  359.      (You can often determine what source file is affected by
  360.      specifying `set verbose on'.  *Note Messages/Warnings::.)
  361.  
  362. `bad block start address patched'
  363.      The symbol information for a symbol scope block has a start
  364.      address smaller than the address of the preceding source line. 
  365.      This is known to occur in the SunOS 4.1.1 (and earlier) C
  366.      compiler.
  367.  
  368.      GDB circumvents the problem by treating the symbol scope block
  369.      as starting on the previous source line.
  370.  
  371. `bad string table offset in symbol N'
  372.      Symbol number N contains a pointer into the string table which
  373.      is larger than the size of the string table.
  374.  
  375.      GDB circumvents the problem by considering the symbol to have
  376.      the name `foo', which may cause other problems if many symbols
  377.      end up with this name.
  378.  
  379. `unknown symbol type `0xNN''
  380.      The symbol information contains new data types that GDB does not
  381.      yet know how to read.  `0xNN' is the symbol type of the
  382.      misunderstood information, in hexadecimal.
  383.  
  384.      GDB circumvents the error by ignoring this symbol information. 
  385.      This will usually allow the program to be debugged, though
  386.      certain symbols will not be accessible.  If you encounter such
  387.      a problem and feel like debugging it, you can debug `gdb' with
  388.      itself, breakpoint on `complain', then go up to the function
  389.      `read_dbx_symtab' and examine `*bufp' to see the symbol.
  390.  
  391. `stub type has NULL name'
  392.      GDB could not find the full definition for a struct or class.
  393.  
  394. `C++ type mismatch between compiler and debugger'
  395.      GDB could not parse a type specification output by the compiler
  396.      for some C++ object.
  397.  
  398. 
  399. File: gdb.info,  Node: Targets,  Next: Controlling GDB,  Prev: GDB Files,  Up: Top
  400.  
  401. Specifying a Debugging Target
  402. *****************************
  403.  
  404.    A "target" is an interface between the debugger and a particular 
  405. kind of file or process.
  406.  
  407.    Often, you will be able to run GDB in the same host environment as
  408. the program you are debugging; in that case, the debugging target
  409. can just be specified as a side effect of the `file' or `core'
  410. commands.  When you need more flexibility--for example, running GDB
  411. on a physically separate host, controlling standalone systems over a
  412. serial port, or realtime systems over a TCP/IP connection--you can
  413. use the `target' command.
  414.  
  415. * Menu:
  416.  
  417. * Active Targets::              Active Targets
  418. * Target Commands::             Commands for Managing Targets
  419. * Remote::                      Remote Debugging
  420.  
  421. 
  422. File: gdb.info,  Node: Active Targets,  Next: Target Commands,  Prev: Targets,  Up: Targets
  423.  
  424. Active Targets
  425. ==============
  426.  
  427.    Targets are managed in three "strata" that correspond to different
  428. classes of target: processes, core files, and executable files. 
  429. This allows you to (for example) start a process and inspect its
  430. activity without abandoning your work on a core file.
  431.  
  432.    More than one target can potentially respond to a request.  In
  433. particular, when you access memory GDB will examine the three strata
  434. of targets until it finds a target that can handle that particular
  435. address.  Strata are always examined in a fixed order: first a
  436. process if there is one, then a core file if there is one, and
  437. finally
  438. an executable file if there is one of those.
  439.  
  440.    When you specify a new target in a given stratum, it replaces any
  441. target previously in that stratum.
  442.  
  443.    To get rid of a target without replacing it, use the `detach'
  444. command.  The related command `attach' provides you with a way of
  445. choosing a particular running process as a new target. *Note Attach::.
  446.  
  447. 
  448. File: gdb.info,  Node: Target Commands,  Next: Remote,  Prev: Active Targets,  Up: Targets
  449.  
  450. Commands for Managing Targets
  451. =============================
  452.  
  453. `target TYPE PARAMETERS'
  454.      Connects the GDB host environment to a target machine or
  455.      process.  A target is typically a protocol for talking to
  456.      debugging facilities.  You use the argument TYPE to specify the
  457.      type or protocol of the target machine.
  458.  
  459.      Further PARAMETERS are interpreted by the target protocol, but
  460.      typically include things like device names or host names to
  461.      connect with, process numbers, and baud rates.
  462.  
  463.      The `target' command will not repeat if you press RET again
  464.      after executing the command.
  465.  
  466. `help target'
  467.      Displays the names of all targets available.  To display targets
  468.      currently selected, use either `info target' or `info files'
  469.      (*note Files::.).
  470.  
  471. `help target NAME'
  472.      Describe a particular target, including any parameters necessary
  473.      to select it.
  474.  
  475.    Here are some common targets (available, or not, depending on the
  476. GDB configuration):
  477.  
  478. `target exec PROG'
  479.      An executable file.  `target exec PROG' is the same as
  480.      `exec-file PROG'.
  481.  
  482. `target core FILENAME'
  483.      A core dump file.  `target core FILENAME' is the same as
  484.      `core-file FILENAME'.
  485.  
  486. `target remote DEV'
  487.      Remote serial target in GDB-specific protocol.  The argument DEV
  488.      specifies what serial device to use for the connection (e.g. 
  489.      `/dev/ttya'). *Note Remote::.
  490.  
  491. `target amd-eb DEV SPEED PROG'
  492.      Remote PC-resident AMD EB29K board, attached over serial lines. 
  493.      DEV is the serial device, as for `target remote'; SPEED allows
  494.      you to specify the linespeed; and PROG is the name of the
  495.      program to be debugged, as it appears to DOS on the PC.  *Note
  496.      EB29K Remote::.
  497.  
  498. `target nindy DEVICENAME'
  499.      An Intel 960 board controlled by a Nindy Monitor.  DEVICENAME is
  500.      the name of the serial device to use for the connection, e.g. 
  501.      `/dev/ttya'.  *Note i960-Nindy Remote::.
  502.  
  503. `target vxworks MACHINENAME'
  504.      A VxWorks system, attached via TCP/IP.  The argument MACHINENAME
  505.      is the target system's machine name or IP address.  *Note
  506.      VxWorks Remote::.
  507.  
  508.    Different targets are available on different configurations of
  509. GDB; your configuration may have more or fewer targets.
  510.  
  511. 
  512. File: gdb.info,  Node: Remote,  Prev: Target Commands,  Up: Targets
  513.  
  514. Remote Debugging
  515. ================
  516.  
  517. * Menu:
  518.  
  519. * i960-Nindy Remote::        
  520. * EB29K Remote::        
  521. * VxWorks Remote::        
  522.  
  523.    If you are trying to debug a program running on a machine that
  524. can't run GDB in the usual way, it is often useful to use remote
  525. debugging.  For example, you might use remote debugging on an
  526. operating system kernel, or on a small system which does not have a
  527. general purpose operating system powerful enough to run a
  528. full-featured debugger.
  529.  
  530.    Some configurations of GDB have special serial or TCP/IP
  531. interfaces to make this work with particular debugging targets.  In
  532. addition,
  533. GDB comes with a generic serial protocol (specific to GDB, but not
  534. specific to any particular target system) which you can use if you
  535. write the remote stubs--the code that will run on the remote system
  536. to
  537. communicate
  538. with GDB.
  539.  
  540.    To use the GDB remote serial protocol, the program to be debugged
  541. on the remote machine needs to contain a debugging stub which talks
  542. to GDB over the serial line.  Several working remote stubs are
  543. distributed with GDB; see the `README' file in the GDB distribution
  544. for more information.
  545.  
  546.    For details of this communication protocol, see the comments in
  547. the GDB source file `remote.c'.
  548.  
  549.    To start remote debugging, first run GDB and specify as an
  550. executable file the program that is running in the remote machine. 
  551. This tells GDB how to find the program's symbols and the contents of
  552. its pure text.  Then establish communication using the `target
  553. remote' command with a device name as an argument.  For example:
  554.  
  555.      target remote /dev/ttyb
  556.  
  557. if the serial line is connected to the device named `/dev/ttyb'. 
  558. This will stop the remote machine if it is not already stopped.
  559.  
  560.    Now you can use all the usual commands to examine and change data
  561. and to step and continue the remote program.
  562.  
  563.    To resume the remote program and stop debugging it, use the
  564. `detach' command.
  565.  
  566.    Other remote targets may be available in your configuration of
  567. GDB; use `help targets' to list them.
  568.  
  569. 
  570. File: gdb.info,  Node: i960-Nindy Remote,  Next: EB29K Remote,  Prev: Remote,  Up: Remote
  571.  
  572. GDB with a Remote i960 (Nindy)
  573. ------------------------------
  574.  
  575.    "Nindy" is a ROM Monitor program for Intel 960 target systems. 
  576. When GDB is configured to control a remote Intel 960 using Nindy,
  577. you can tell GDB how to connect to the 960 in several ways:
  578.  
  579.    * Through command line options specifying serial port, version of
  580.      the Nindy protocol, and communications speed;
  581.  
  582.    * By responding to a prompt on startup;
  583.  
  584.    * By using the `target' command at any point during your GDB
  585.      session.  *Note Target Commands::.
  586.  
  587. * Menu:
  588.  
  589. * Nindy Startup::        Startup with Nindy
  590. * Nindy Options::        Options for Nindy
  591. * Nindy reset::            Nindy Reset Command
  592.  
  593. 
  594. File: gdb.info,  Node: Nindy Startup,  Next: Nindy Options,  Prev: i960-Nindy Remote,  Up: i960-Nindy Remote
  595.  
  596. Startup with Nindy
  597. ..................
  598.  
  599.    If you simply start `GDB' without using any command-line options,
  600. you are prompted for what serial port to use, *before* you reach the
  601. ordinary GDB prompt:
  602.  
  603.      Attach /dev/ttyNN -- specify NN, or "quit" to quit:
  604.  
  605. Respond to the prompt with whatever suffix (after `/dev/tty')
  606. identifies the serial port you want to use.  You can, if you choose,
  607. simply start up with no Nindy connection by responding to the prompt
  608. with an empty line.  If you do this, and later wish to attach to
  609. Nindy, use `target' (*note Target Commands::.).
  610.  
  611. 
  612. File: gdb.info,  Node: Nindy Options,  Next: Nindy reset,  Prev: Nindy Startup,  Up: i960-Nindy Remote
  613.  
  614. Options for Nindy
  615. .................
  616.  
  617.    These are the startup options for beginning your GDB session with
  618. a Nindy-960 board attached:
  619.  
  620. `-r PORT'
  621.      Specify the serial port name of a serial interface to be used to
  622.      connect to the target system.  This option is only available
  623.      when GDB is configured for the Intel 960 target architecture. 
  624.      You may specify PORT as any of: a full pathname (e.g. `-r
  625.      /dev/ttya'), a device name in `/dev' (e.g. `-r ttya'), or
  626.      simply
  627.      the unique suffix for a specific `tty' (e.g. `-r a').
  628.  
  629. `-O'
  630.      (An uppercase letter "O", not a zero.)  Specify that GDB should
  631.      use the "old" Nindy monitor protocol to connect to the target
  632.      system.  This option is only available when GDB is configured
  633.      for the Intel 960 target architecture.
  634.  
  635.           *Warning:* if you specify `-O', but are actually trying to
  636.           connect to a target system that expects the newer
  637.           protocol, the connection will fail, appearing to be a
  638.           speed mismatch.  GDB will repeatedly attempt to reconnect
  639.           at several different line speeds.  You can abort this
  640.          
  641.           process with an interrupt.
  642.  
  643. `-brk'
  644.      Specify that GDB should first send a `BREAK' signal to the
  645.      target system, in an attempt to reset it, before connecting to
  646.      a Nindy target.
  647.  
  648.           *Warning:* Many target systems do not have the hardware
  649.           that this requires; it only works with a few boards.
  650.  
  651.    The standard `-b' option controls the line speed used on the
  652. serial port.
  653.  
  654. 
  655. File: gdb.info,  Node: Nindy reset,  Prev: Nindy Options,  Up: i960-Nindy Remote
  656.  
  657. Nindy Reset Command
  658. ...................
  659.  
  660. `reset'
  661.      For a Nindy target, this command sends a "break" to the remote
  662.      target system; this is only useful if the target has been
  663.      equipped with a circuit to perform a hard reset (or some other
  664.      interesting action) when a break is detected.
  665.  
  666. 
  667. File: gdb.info,  Node: EB29K Remote,  Next: VxWorks Remote,  Prev: i960-Nindy Remote,  Up: Remote
  668.  
  669. GDB with a Remote EB29K
  670. -----------------------
  671.  
  672.    To use GDB from a Unix system to run programs on AMD's EB29K board
  673. in a PC, you must first connect a serial cable between the PC and a
  674. serial port on the Unix system.  In the following, we assume you've
  675. hooked the cable between the PC's `COM1' port and `/dev/ttya' on the
  676. Unix system.
  677.  
  678. * Menu:
  679.  
  680. * Comms (EB29K)::        Communications Setup
  681. * gdb-EB29K::            EB29K cross-debugging
  682. * Remote Log::            Remote Log
  683.  
  684. 
  685. File: gdb.info,  Node: Comms (EB29K),  Next: gdb-EB29K,  Prev: EB29K Remote,  Up: EB29K Remote
  686.  
  687. Communications Setup
  688. ....................
  689.  
  690.    The next step is to set up the PC's port, by doing something like
  691. the following in DOS on the PC:
  692.  
  693.      C:\> MODE com1:9600,n,8,1,none
  694.  
  695. This example--run on an MS DOS 4.0 system--sets the PC port to 9600
  696. bps, no parity, eight data bits, one stop bit, and no "retry"
  697. action; you must match the communications parameters when
  698. establishing the Unix end of the connection as well.
  699.  
  700.    To give control of the PC to the Unix side of the serial line,
  701. type the following at the DOS console:
  702.  
  703.      C:\> CTTY com1
  704.  
  705. (Later, if you wish to return control to the DOS console, you can use
  706. the command `CTTY con'--but you must send it over the device that
  707. had control, in our example over the `COM1' serial line).
  708.  
  709.    From the Unix host, use a communications program such as `tip' or
  710. `cu' to communicate with the PC; for example,
  711.  
  712.      cu -s 9600 -l /dev/ttya
  713.  
  714. The `cu' options shown specify, respectively, the linespeed and the
  715. serial port to use.  If you use `tip' instead, your command line may
  716. look something like the following:
  717.  
  718.      tip -9600 /dev/ttya
  719.  
  720. Your system may define a different name where our example uses
  721. `/dev/ttya' as the argument to `tip'.  The communications
  722. parameters, including what port to use, are associated with the
  723. `tip' argument in the "remote" descriptions file--normally the
  724. system table `/etc/remote'.
  725.  
  726.    Using the `tip' or `cu' connection, change the DOS working
  727. directory to the directory containing a copy of your 29K program,
  728. then start the PC program `EBMON' (an EB29K control program supplied
  729. with your board by AMD).  You should see an initial display from
  730. `EBMON' similar to the one that follows, ending with the `EBMON'
  731. prompt `#'--
  732.  
  733.      C:\> G:
  734.      
  735.      G:\> CD \usr\joe\work29k
  736.      
  737.      G:\USR\JOE\WORK29K> EBMON
  738.      Am29000 PC Coprocessor Board Monitor, version 3.0-18
  739.      Copyright 1990 Advanced Micro Devices, Inc.
  740.      Written by Gibbons and Associates, Inc.
  741.      
  742.      Enter '?' or 'H' for help
  743.      
  744.      PC Coprocessor Type   = EB29K
  745.      I/O Base              = 0x208
  746.      Memory Base           = 0xd0000
  747.      
  748.      Data Memory Size      = 2048KB
  749.      Available I-RAM Range = 0x8000 to 0x1fffff
  750.      Available D-RAM Range = 0x80002000 to 0x801fffff
  751.      
  752.      PageSize              = 0x400
  753.      Register Stack Size   = 0x800
  754.      Memory Stack Size     = 0x1800
  755.      
  756.      CPU PRL               = 0x3
  757.      Am29027 Available     = No
  758.      Byte Write Available  = Yes
  759.      
  760.      # ~.
  761.  
  762.    Then exit the `cu' or `tip' program (done in the example by typing
  763. `~.' at the `EBMON' prompt).  `EBMON' will keep running, ready for
  764. GDB to take over.
  765.  
  766.    For this example, we've assumed what is probably the most
  767. convenient way to make sure the same 29K program is on both the PC
  768. and the Unix system: a PC/NFS connection that establishes "drive
  769. `G:'" on the PC as a file system on the Unix host.  If you don't
  770. have PC/NFS or something similar connecting the two systems, you
  771. must arrange some other way--perhaps floppy-disk transfer--of
  772. getting
  773. the 29K program from the Unix system to the PC; GDB will *not*
  774. download it over the serial line.
  775.  
  776. 
  777. File: gdb.info,  Node: gdb-EB29K,  Next: Remote Log,  Prev: Comms (EB29K),  Up: EB29K Remote
  778.  
  779. EB29K cross-debugging
  780. .....................
  781.  
  782.    Finally, `cd' to the directory containing an image of your 29K
  783. program on the Unix system, and start GDB--specifying as argument
  784. the name of your 29K program:
  785.  
  786.      cd /usr/joe/work29k
  787.      gdb myfoo
  788.  
  789.    Now you can use the `target' command:
  790.  
  791.      target amd-eb /dev/ttya 9600 MYFOO
  792.  
  793. In this example, we've assumed your program is in a file called
  794. `myfoo'.  Note that the filename given as the last argument to
  795. `target amd-eb' should be the name of the program as it appears to
  796. DOS.  In our example this is simply `MYFOO', but in general it can
  797. include a DOS path, and depending on your transfer mechanism may not
  798. resemble the name on the Unix side.
  799.  
  800.    At this point, you can set any breakpoints you wish; when you're
  801. ready to see your program run on the 29K board, use the GDB command
  802. `run'.
  803.  
  804.    To stop debugging the remote program, use the GDB `detach'
  805. command.
  806.  
  807.    To return control of the PC to its console, use `tip' or `cu' once
  808. again,
  809. after your GDB session has concluded, to attach to `EBMON'.  You can
  810. then type the command `q' to shut down `EBMON', returning control to
  811. the DOS command-line interpreter.  Type `CTTY con' to return command
  812. input to the main DOS console, and type `~.' to leave `tip' or `cu'.
  813.  
  814. 
  815. File: gdb.info,  Node: Remote Log,  Prev: gdb-EB29K,  Up: EB29K Remote
  816.  
  817. Remote Log
  818. ..........
  819.  
  820.    The `target amd-eb' command creates a file `eb.log' in the current
  821. working directory, to help debug problems with the connection. 
  822. `eb.log' records all the output from `EBMON', including echoes of
  823. the commands sent to it.  Running `tail -f' on this file in another
  824. window often helps to understand trouble with `EBMON', or unexpected
  825. events on the PC side of the connection.
  826.  
  827. 
  828. File: gdb.info,  Node: VxWorks Remote,  Prev: EB29K Remote,  Up: Remote
  829.  
  830. GDB and VxWorks
  831. ---------------
  832.  
  833.    GDB enables developers to spawn and debug tasks running on
  834. networked VxWorks targets from a Unix host.  Already-running tasks
  835. spawned from the VxWorks shell can also be debugged.  GDB uses code
  836. that
  837. runs on both the UNIX host and on the VxWorks target.  The program
  838. `gdb' is installed and executed on the UNIX host.
  839.  
  840.    The remote debugging interface (RDB) routines are installed and
  841. executed on the VxWorks target.  These routines are included in the
  842. VxWorks library `rdb.a' and are incorporated into the system image
  843. when source-level debugging is enabled in the VxWorks configuration.
  844.  
  845.    Defining `INCLUDE_RDB' in the VxWorks configuration file
  846. `configAll.h' includes the RDB interface routines and spawns the
  847. source debugging task `tRdbTask' when VxWorks is booted.  For more
  848. information on configuring and remaking VxWorks, see the `VxWorks
  849. Programmer's Guide'.
  850.  
  851.    Once you have included the RDB interface in your VxWorks system
  852. image and set your Unix execution search path to find GDB, you are
  853. ready to run GDB.  From your UNIX host, type:
  854.  
  855.      % gdb
  856.  
  857.    GDB will come up showing the prompt:
  858.  
  859.      (gdb)
  860.  
  861. * Menu:
  862.  
  863. * VxWorks connection::        Connecting to VxWorks
  864. * VxWorks download::        VxWorks Download
  865. * VxWorks attach::        Running Tasks
  866.  
  867. 
  868. File: gdb.info,  Node: VxWorks connection,  Next: VxWorks download,  Prev: VxWorks Remote,  Up: VxWorks Remote
  869.  
  870. Connecting to VxWorks
  871. .....................
  872.  
  873.    The GDB command `target' lets you connect to a VxWorks target on
  874. the network.  To connect to a target whose host name is "`tt'", type:
  875.  
  876.      (gdb) target vxworks tt
  877.  
  878.    GDB will display a message similar to the following:
  879.  
  880.      Attaching remote machine across net... Success!
  881.  
  882.    GDB will then attempt to read the symbol tables of any object
  883. modules loaded into the VxWorks target since it was last booted. 
  884. GDB locates these files by searching the directories listed in the
  885. command search path (*note Environment::.); if it fails to find an
  886. object file, it will display a message such as:
  887.  
  888.      prog.o: No such file or directory.
  889.  
  890.    This will cause the `target' command to abort.  When this happens,
  891. you should add the appropriate directory to the search path, with
  892. the GDB command `path', and execute the `target' command again.
  893.  
  894. 
  895. File: gdb.info,  Node: VxWorks download,  Next: VxWorks attach,  Prev: VxWorks connection,  Up: VxWorks Remote
  896.  
  897. VxWorks Download
  898. ................
  899.  
  900.    If you have connected to the VxWorks target and you want to debug
  901. an object that has not yet been loaded, you can use the GDB `load'
  902. command to download a file from UNIX to VxWorks incrementally.  The
  903. object file given as an argument to the `load' command is actually
  904. opened twice: first by the VxWorks target in order to download the
  905. code, then by GDB in order to read the symbol table.  This can lead
  906. to problems if the current working directories on the two systems
  907. differ.  It is simplest to set the working directory on both systems
  908. to the directory in which the object file resides, and then to
  909. reference the file by its name, without any path.  Thus, to load a
  910. program `prog.o', residing in `wherever/vw/demo/rdb', on VxWorks type:
  911.  
  912.      -> cd "wherever/vw/demo/rdb"
  913.  
  914.    On GDB type:
  915.  
  916.      (gdb) cd wherever/vw/demo/rdb 
  917.      (gdb) load prog.o
  918.  
  919.    GDB will display a response similar to the following:
  920.  
  921.      Reading symbol data from wherever/vw/demo/rdb/prog.o... done.
  922.  
  923.    You can also use the `load' command to reload an object module
  924. after
  925. editing and recompiling the corresponding source file.  Note that
  926. this will cause GDB to delete all currently-defined breakpoints,
  927. auto-displays, and convenience variables, and to clear the value
  928. history.  (This is necessary in order to preserve the integrity of
  929. debugger data structures that reference the target system's symbol
  930. table.)
  931.  
  932. 
  933. File: gdb.info,  Node: VxWorks attach,  Prev: VxWorks download,  Up: VxWorks Remote
  934.  
  935. Running Tasks
  936. .............
  937.  
  938.    You can also attach to an existing task using the `attach' command
  939. as follows:
  940.  
  941.      (gdb) attach TASK
  942.  
  943.    where TASK is the VxWorks hexadecimal task ID.  The task can be
  944. running or suspended when you attach to it.  If running, it will be
  945. suspended
  946. at the time of attachment.
  947.  
  948. 
  949. File: gdb.info,  Node: Controlling GDB,  Next: Sequences,  Prev: Targets,  Up: Top
  950.  
  951. Controlling GDB
  952. ***************
  953.  
  954.    You can alter many aspects of GDB's interaction with you by using
  955. the `set' command.  For commands controlling how GDB displays data,
  956. *note Print Settings::.; other settings are described here.
  957.  
  958. * Menu:
  959.  
  960. * Prompt::                      Prompt
  961. * Editing::                     Command Editing
  962. * History::                     Command History
  963. * Screen Size::                 Screen Size
  964. * Numbers::                     Numbers
  965. * Messages/Warnings::           Optional Warnings and Messages
  966.  
  967. 
  968. File: gdb.info,  Node: Prompt,  Next: Editing,  Prev: Controlling GDB,  Up: Controlling GDB
  969.  
  970. Prompt
  971. ======
  972.  
  973.    GDB indicates its readiness to read a command by printing a string
  974. called the "prompt".  This string is normally `(gdb)'.  You can
  975. change the prompt string with the `set prompt' command.  For
  976. instance, when debugging GDB with GDB, it is useful to change the
  977. prompt in one of the GDBs so that you can always tell which one you
  978. are talking to.
  979.  
  980. `set prompt NEWPROMPT'
  981.      Directs GDB to use NEWPROMPT as its prompt string henceforth.
  982.  
  983. `show prompt'
  984.      Prints a line of the form: `Gdb's prompt is: YOUR-PROMPT'
  985.  
  986. 
  987. File: gdb.info,  Node: Editing,  Next: History,  Prev: Prompt,  Up: Controlling GDB
  988.  
  989. Command Editing
  990. ===============
  991.  
  992.    GDB reads its input commands via the "readline" interface.  This
  993. GNU library provides consistent behavior for programs which provide
  994. a command line interface to the user.  Advantages are `emacs'-style
  995. or `vi'-style inline editing of commands, `csh'-like history
  996. substitution, and a storage and recall of command history across
  997. debugging sessions.
  998.  
  999.    You may control the behavior of command line editing in GDB with
  1000. the command `set'.
  1001.  
  1002. `set editing'
  1003. `set editing on'
  1004.      Enable command line editing (enabled by default).
  1005.  
  1006. `set editing off'
  1007.      Disable command line editing.
  1008.  
  1009. `show editing'
  1010.      Show whether command line editing is enabled.
  1011.  
  1012. 
  1013. File: gdb.info,  Node: History,  Next: Screen Size,  Prev: Editing,  Up: Controlling GDB
  1014.  
  1015. Command History
  1016. ===============
  1017.  
  1018. `set history filename FNAME'
  1019.      Set the name of the GDB command history file to FNAME.  This is
  1020.      the file from which GDB will read an initial command history
  1021.      list or to which it will write this list when it exits.  This
  1022.      list is accessed through history expansion or through the
  1023.      history command editing characters listed below.  This file
  1024.      defaults to the value of the environment variable
  1025.      `GDBHISTFILE', or to `./.gdb_history' if this variable is not
  1026.      set.
  1027.  
  1028. `set history save'
  1029. `set history save on'
  1030.      Record command history in a file, whose name may be specified
  1031.      with the `set history filename' command.  By default, this
  1032.      option is disabled.
  1033.  
  1034. `set history save off'
  1035.      Stop recording command history in a file.
  1036.  
  1037. `set history size SIZE'
  1038.      Set the number of commands which GDB will keep in its history
  1039.      list.  This defaults to the value of the environment variable
  1040.      `HISTSIZE', or to 256 if this variable is not set.
  1041.  
  1042.    History expansion assigns special meaning to the character `!'. 
  1043. Since `!' is also the logical not operator in C, history expansion
  1044. is off by default. If you decide to enable history expansion with
  1045. the `set history expansion on' command, you may sometimes need to
  1046. follow `!' (when it is used as logical not, in an expression) with a
  1047. space or a tab to prevent it from being expanded.  The readline
  1048. history facilities will not attempt substitution on the strings `!='
  1049. and `!(', even when history expansion is enabled.
  1050.  
  1051.    The commands to control history expansion are:
  1052.  
  1053. `set history expansion on'
  1054. `set history expansion'
  1055.      Enable history expansion.  History expansion is off by default.
  1056.  
  1057. `set history expansion off'
  1058.      Disable history expansion.
  1059.  
  1060.      The readline code comes with more complete documentation of
  1061.      editing and history expansion features.  Users unfamiliar with
  1062.      `emacs' or `vi' may wish to read it.
  1063.  
  1064. `show history'
  1065. `show history filename'
  1066. `show history save'
  1067. `show history size'
  1068. `show history expansion'
  1069.      These commands display the state of the GDB history parameters. 
  1070.      `show history' by itself displays all four states.
  1071.  
  1072. `show commands'
  1073.      Display the last ten commands in the command history.
  1074.  
  1075. `show commands N'
  1076.      Print ten commands centered on command number N.
  1077.  
  1078. `show commands +'
  1079.      Print ten commands just after the commands last printed.
  1080.  
  1081. 
  1082. File: gdb.info,  Node: Screen Size,  Next: Numbers,  Prev: History,  Up: Controlling GDB
  1083.  
  1084. Screen Size
  1085. ===========
  1086.  
  1087.    Certain commands to GDB may produce large amounts of information
  1088. output to the screen.  To help you read all of it, GDB pauses and
  1089. asks you for input at the end of each page of output.  Type RET when
  1090. you want to continue the output.  GDB also uses the screen width
  1091. setting to determine when to wrap lines of output.  Depending on
  1092. what is being printed, it tries to break the line at a readable
  1093. place, rather than simply letting it overflow onto the following line.
  1094.  
  1095.    Normally GDB knows the size of the screen from the termcap data
  1096. base together with the value of the `TERM' environment variable and
  1097. the `stty rows' and `stty cols' settings. If this is not correct,
  1098. you can override it with the `set height' and `set width' commands:
  1099.  
  1100. `set height LPP'
  1101. `show height'
  1102. `set width CPL'
  1103. `show width'
  1104.      These `set' commands specify a screen height of LPP lines and a
  1105.      screen width of CPL characters.  The associated `show' commands
  1106.      display the current settings.
  1107.  
  1108.      If you specify a height of zero lines, GDB will not pause during
  1109.      output no matter how long the output is.  This is useful if
  1110.      output is to a file or to an editor buffer.
  1111.  
  1112. 
  1113. File: gdb.info,  Node: Numbers,  Next: Messages/Warnings,  Prev: Screen Size,  Up: Controlling GDB
  1114.  
  1115. Numbers
  1116. =======
  1117.  
  1118.    You can always enter numbers in octal, decimal, or hexadecimal in
  1119. GDB by the usual conventions: octal numbers begin with `0', decimal
  1120. numbers end with `.', and hexadecimal numbers begin with `0x'. 
  1121. Numbers that begin with none of these are, by default, entered in
  1122. base 10; likewise, the default display for numbers--when no
  1123. particular format is specified--is base 10.  You can change the
  1124. default base for both input and output with the `set radix' command.
  1125.  
  1126. `set radix BASE'
  1127.      Set the default base for numeric input and display.  Supported
  1128.      choices for BASE are decimal 8, 10, 16.  BASE must itself be
  1129.      specified either unambiguously or using the current default
  1130.      radix; for example, any of
  1131.  
  1132.           set radix 012
  1133.           set radix 10.
  1134.           set radix 0xa
  1135.  
  1136.      will set the base to decimal.  On the other hand, `set radix 10'
  1137.     
  1138.      will leave the radix unchanged no matter what it was.
  1139.  
  1140. `show radix'
  1141.      Display the current default base for numeric input and display.
  1142.  
  1143. 
  1144. File: gdb.info,  Node: Messages/Warnings,  Prev: Numbers,  Up: Controlling GDB
  1145.  
  1146. Optional Warnings and Messages
  1147. ==============================
  1148.  
  1149.    By default, GDB is silent about its inner workings.  If you are
  1150. running on a slow machine, you may want to use the `set verbose'
  1151. command.  It will make GDB tell you when it does a lengthy internal
  1152. operation, so you won't think it has crashed.
  1153.  
  1154.    Currently, the messages controlled by `set verbose' are those
  1155. which announce that the symbol table for a source file is being read
  1156. (*note Files::., in the description of the command `symbol-file').
  1157.  
  1158. `set verbose on'
  1159.      Enables GDB's output of certain informational messages.
  1160.  
  1161. `set verbose off'
  1162.      Disables GDB's output of certain informational messages.
  1163.  
  1164. `show verbose'
  1165.      Displays whether `set verbose' is on or off.
  1166.  
  1167.    By default, if GDB encounters bugs in the symbol table of an
  1168. object file, it is silent; but if you are debugging a compiler, you
  1169. may find this information useful (*note Symbol Errors::.).
  1170.  
  1171. `set complaints LIMIT'
  1172.      Permits GDB to output LIMIT complaints about each type of
  1173.      unusual symbols before becoming silent about the problem.  Set
  1174.      LIMIT to zero to suppress all complaints; set it to a large
  1175.      number to prevent complaints from being suppressed.
  1176.  
  1177. `show complaints'
  1178.      Displays how many symbol complaints GDB is permitted to produce.
  1179.  
  1180.    By default, GDB is cautious, and asks what sometimes seem to be a
  1181. lot of stupid questions to confirm certain commands.  For example,
  1182. if you try to run a program which is already running:
  1183.  
  1184.      (gdb) run
  1185.      The program being debugged has been started already.
  1186.      Start it from the beginning? (y or n)
  1187.  
  1188.    If you're willing to unflinchingly face the consequences of your
  1189. own
  1190. commands, you can disable this "feature":
  1191.  
  1192. `set confirm off'
  1193.      Disables confirmation requests.
  1194.  
  1195. `set confirm on'
  1196.      Enables confirmation requests (the default).
  1197.  
  1198. `show confirm'
  1199.      Displays state of confirmation requests.
  1200.  
  1201.    Some systems allow individual object files that make up your
  1202. program
  1203. to be replaced without stopping and restarting your program.  For
  1204. example, in VxWorks you can simply recompile a defective object file
  1205. and keep on running.  If you're running on one of these systems, you
  1206. can allow GDB to reload the symbols for automatically relinked
  1207. modules:
  1208.  
  1209. `set symbol-reloading on'
  1210.      Replace symbol definitions for the corresponding source file
  1211.      when an object file with a particular name is seen again.
  1212.  
  1213. `set symbol-reloading off'
  1214.      Don't replace symbol definitions when re-encountering object
  1215.      files of the same name.  This is the default state; if you're
  1216.      not running on a system that permits automatically relinking
  1217.      modules, you should leave `symbol-reloading' off, since
  1218.      otherwise GDB may discard symbols when linking large programs,
  1219.      that may contain several modules (from different directories or
  1220.      libraries) with the same name.
  1221.  
  1222. `show symbol-reloading'
  1223.      Show the current `on' or `off' setting.
  1224.  
  1225. 
  1226. File: gdb.info,  Node: Sequences,  Next: Emacs,  Prev: Controlling GDB,  Up: Top
  1227.  
  1228. Canned Sequences of Commands
  1229. ****************************
  1230.  
  1231.    Aside from breakpoint commands (*note Break Commands::.), GDB
  1232. provides two ways to store sequences of commands for execution as a
  1233. unit: user-defined commands and command files.
  1234.  
  1235. * Menu:
  1236.  
  1237. * Define::                      User-Defined Commands
  1238. * Command Files::               Command Files
  1239. * Output::                      Commands for Controlled Output
  1240.  
  1241. 
  1242. File: gdb.info,  Node: Define,  Next: Command Files,  Prev: Sequences,  Up: Sequences
  1243.  
  1244. User-Defined Commands
  1245. =====================
  1246.  
  1247.    A "user-defined command" is a sequence of GDB commands to which
  1248. you assign a new name as a command.  This is done with the `define'
  1249. command.
  1250.  
  1251. `define COMMANDNAME'
  1252.      Define a command named COMMANDNAME.  If there is already a
  1253.      command by that name, you are asked to confirm that you want to
  1254.      redefine it.
  1255.  
  1256.      The definition of the command is made up of other GDB command
  1257.      lines, which are given following the `define' command.  The end
  1258.      of these commands is marked by a line containing `end'.
  1259.  
  1260. `document COMMANDNAME'
  1261.      Give documentation to the user-defined command COMMANDNAME.  The
  1262.      command COMMANDNAME must already be defined.  This command
  1263.      reads lines of documentation just as `define' reads the lines
  1264.      of the command definition, ending with `end'.  After the
  1265.      `document' command is finished, `help' on command COMMANDNAME
  1266.      will print the documentation you have specified.
  1267.  
  1268.      You may use the `document' command again to change the
  1269.      documentation of a command.  Redefining the command with
  1270.      `define' does not change the documentation.
  1271.  
  1272. `help user-defined'
  1273.      List all user-defined commands, with the first line of the
  1274.      documentation (if any) for each.
  1275.  
  1276. `info user'
  1277. `info user COMMANDNAME'
  1278.      Display the GDB commands used to define COMMANDNAME (but not its
  1279.      documentation).  If no COMMANDNAME is given, display the
  1280.      definitions for all user-defined commands.
  1281.  
  1282.    User-defined commands do not take arguments.  When they are
  1283. executed, the commands of the definition are not printed.  An error
  1284. in any command stops execution of the user-defined command.
  1285.  
  1286.    Commands that would ask for confirmation if used interactively
  1287. proceed without asking when used inside a user-defined command. 
  1288. Many GDB commands that normally print messages to say what they are
  1289. doing omit the messages when used in a user-defined command.
  1290.  
  1291. 
  1292. File: gdb.info,  Node: Command Files,  Next: Output,  Prev: Define,  Up: Sequences
  1293.  
  1294. Command Files
  1295. =============
  1296.  
  1297.    A command file for GDB is a file of lines that are GDB commands. 
  1298. Comments (lines starting with `#') may also be included.  An empty
  1299. line in a command file does nothing; it does not mean to repeat the
  1300. last command, as it would from the terminal.
  1301.  
  1302.    When you start GDB, it automatically executes commands from its
  1303. "init files".  These are files named `.gdbinit'.  GDB reads the init
  1304. file (if any) in your home directory and then the init file (if any)
  1305. in the current working directory.  (The init files are not executed
  1306. if you use the `-nx' option; *note Mode Options::..)  You can also
  1307. request the execution of a command file with the `source' command:
  1308.  
  1309. `source FILENAME'
  1310.      Execute the command file FILENAME.
  1311.  
  1312.    The lines in a command file are executed sequentially.  They are
  1313. not printed as they are executed.  An error in any command
  1314. terminates execution of the command file.
  1315.  
  1316.    Commands that would ask for confirmation if used interactively
  1317. proceed without asking when used in a command file.  Many GDB
  1318. commands that normally print messages to say what they are doing
  1319. omit the messages when called from command files.
  1320.  
  1321.